import Vue from 'vue';
import Router from 'vue-router';

/* layout */
import Layout from '../views/layout/Layout';
import AppMain from '../views/layout/AppMain';

/* login */
import Login from '../views/login/';
const authRedirect = resolve => require(['../views/login/authredirect'], resolve);
const sendPWD = resolve => require(['../views/login/sendpwd'], resolve);
const reset = resolve => require(['../views/login/reset'], resolve);

/* home */
const home = resolve => require(['../views/home/index'], resolve);

/* Introduction */
const Introduction = resolve => require(['../views/introduction/index'], resolve);

/* error page */
const Err404 = resolve => require(['../views/error/404'], resolve);
const Err401 = resolve => require(['../views/error/401'], resolve);
const error = resolve => require(['../views/error/serverMaintenance'], resolve);

/* error log */
const ErrorLog = resolve => require(['../views/errlog/index'], resolve);

/* theme  */
const Theme = resolve => require(['../views/theme/index'], resolve);

const logiLayout = resolve => require(['../views/layout/logiLayout'], resolve);


// 权限管理
const authorityComponent = resolve => require(['../views/systemManage/authorityManagement'], resolve);
const addAuthority = resolve => require(['../views/systemManage/authorityManagement/addAuthor'], resolve);
const editAuthority = resolve => require(['../views/systemManage/authorityManagement/editAuthor'], resolve);
const showAuthority = resolve => require(['../views/systemManage/authorityManagement/showAuthor'], resolve);


// 用戶拉新
const areaSchoolCount = resolve => require(['../views/platformAnalysis/userUpdate/areaSchoolCount'], resolve);//区域学校分类
// const classUserCount = resolve => require(['../views/platformAnalysis/userUpdate/classUserCount'], resolve);//班级用户统计
const schoolUserCount = resolve => require(['../views/platformAnalysis/userUpdate/schoolUserCount'], resolve);//学校用户统计
const newAddUserCount = resolve => require(['../views/platformAnalysis/userUpdate/newAddUserCount'], resolve);//新增用户统计

// 数据总览
const dataOverview = resolve => require(['../views/home/overView'], resolve);

// 用户活跃  
const userActivityTrend = resolve => require(['../views/platformAnalysis/userActive/userActivityTrend'], resolve);
const rolesActiveDetail = resolve => require(['../views/platformAnalysis/userActive/rolesActiveDetail'], resolve);
const userActiveFrequency = resolve => require(['../views/platformAnalysis/userActive/userActiveFrequency'], resolve);
const activeModules = resolve => require(['../views/platformAnalysis/userActive/activeModules'], resolve);

// 用户留存
const retenAnalyze = resolve => require(['../views/platformAnalysis/usersRetention/retenAnalyze'], resolve);
const retenStatistics = resolve => require(['../views/platformAnalysis/usersRetention/retenStatistics'], resolve);

// 使用深度
const userLoginStatus = resolve => require(['../views/platformAnalysis/useDepth/userLoginStatus'], resolve);
const userStayLength = resolve => require(['../views/platformAnalysis/useDepth/userStayLength'], resolve);

// 平台消费情况
const cashConsumption = resolve => require(['../views/platformAnalysis/platformConsumption/cashConsumption'], resolve);
const cashConsuContent = resolve => require(['../views/platformAnalysis/platformConsumption/cashConsuContent'], resolve);
// const serviceStatistics = resolve => require(['../views/platformAnalysis/platformConsumption/serviceStatistics'], resolve);

// 设备终端分析
const machineTypeDistribute = resolve => require(['../views/platformAnalysis/deviceTerminalAnalysis/machineTypeDistribute'], resolve);
const resolutionDistribute = resolve => require(['../views/platformAnalysis/deviceTerminalAnalysis/resolutionDistribute'], resolve);
const eCloudDistribute = resolve => require(['../views/platformAnalysis/deviceTerminalAnalysis/eCloudDistribute'], resolve);

// 异动侦查
const changesSee = resolve => require(['../views/platformAnalysis/changesSee/changesSee'], resolve);//侦查
const creditCount = resolve => require(['../views/platformAnalysis/changesSee/creditCount'], resolve);//侦查

// 管理指标分析 模块

// 作业分析
// 管理指标分析
const homework = resolve => require(['../views/manageAnalysis/homework/homework'], resolve);//作业分析
const question = resolve => require(['../views/manageAnalysis/question/question'], resolve);//题库作业
const outHomeWork = resolve => require(['../views/manageAnalysis/outHomeWork/outHomeWork'], resolve);//课外作业

// 课程分析
const classStudy = resolve => require(['../views/manageAnalysis/classStudy/classStudy'], resolve);//课外作业
// 空中课堂
const flyClass = resolve => require(['../views/manageAnalysis/flyClass/flyClass'], resolve);//课外作业

// 积分商城
const creditShop = resolve => require(['../views/manageAnalysis/creditShop/creditShop'], resolve);//课外作业
// 广告
const advert = resolve => require(['../views/manageAnalysis/advert/advert'], resolve);//课外作业

// 活动管理
const newbieTask = resolve => require(['../views/manageAnalysis/activityManage/newbieTask'], resolve); // 新手任务

// 提分中心
const mentionSubCenter = resolve => require(['../views/manageAnalysis/mentionSubCenter/dataAnalysis'], resolve);

// e直播服务分析
const liveServiceStatistics = resolve => require(['../views/manageAnalysis/livingServerAnalysis/liveServiceStatistics'], resolve);
const LiveDetailStatistics = resolve => require(['../views/manageAnalysis/livingServerAnalysis/LiveDetailStatistics'], resolve);

// 积分情况分析
const integralChartStatistics = resolve => require(['../views/manageAnalysis/integrationAnalysis/integralChartStatistics'], resolve);
const integralDetailStatistics = resolve => require(['../views/manageAnalysis/integrationAnalysis/integralDetailStatistics'], resolve);

// 运维服务器监控系统
const opServerMonitoring = resolve => require(['../views/home/opServerMonitoring'], resolve);
const exueMonitoring = resolve => require(['../views/home/exueMonitoring'], resolve);

// 修改密码
const updataPassword = resolve => require(['../views/userManage/updataPassword'], resolve);

// 学情分析
const weaknessKnowledge = resolve => require(['../views/manageAnalysis/studentAnalysis/weaknessKnowledge'], resolve);
const knowledgeExercise = resolve => require(['../views/manageAnalysis/studentAnalysis/knowledgeExercise'], resolve);
// const chapterExercise = resolve => require(['../views/manageAnalysis/studentAnalysis/chapterExercise'], resolve);

// 系统
const userManage = resolve => require(['../views/systemManage/userManagement/userManage'], resolve); // 员工管理
const authority = resolve => require(['../views/systemManage/authorityManagement/index'], resolve); // 权限管理
const addAuthor = resolve => require(['../views/systemManage/authorityManagement/addAuthor'], resolve); // 添加角色
const editAuthor = resolve => require(['../views/systemManage/authorityManagement/editAuthor'], resolve); 
const showAuthor = resolve => require(['../views/systemManage/authorityManagement/showAuthor'], resolve); 

// 漏斗分析
const funnelAnaly = resolve => require(['../views/manageAnalysis/funnelAnalysis/funnelAnaly'], resolve); 

Vue.use(Router);


/**
 * icon : the icon show in the sidebar
 * hidden : if hidden:true will not show in the sidebar
 * redirect : if redirect:noredirect will not redirect in the levelbar
 * isMenu : if isMenu:true will not has submenu
 * meta : { role: ['admin'] }  will control the page role
 **/

export const constantRouterMap = [
    { path: '/login', component: Login, hidden: true },
    { path: '/authredirect', component: authRedirect, hidden: true },
    { path: '/sendpwd', component: sendPWD, hidden: true },
    { path: '/reset', component: reset, hidden: true },
    {
        path: '/userInfor',
        redirect: '/userInfor/updataPassword',
        component: Layout,
        icon: 'quanxian',
        name: "用户",
        children: [
            { path: '/userInfor/updataPassword', component: updataPassword, name: '修改密码' },
        ]  
    },
    {
        path: '/404',
        component: Layout,
        redirect: '/404/index',
        hidden: true,
        children: [
            { path: 'index', component: Err404 }
        ]
    },
    // { path: '/404', component: Err404, hidden: true },
    { path: '/401', component: Err401, hidden: true },
    { path: '/error', component: error, hidden: true }
]

export default new Router({
    // mode: 'history', //后端支持可开
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRouterMap
});

export const homeRouterMap = [
    {
        path: '/',
        component: Layout,
        redirect: '/home',
        name: '首页',
        hidden: true
    },
    {
        path: '/home',
        component: Layout,
        redirect: '/home/dataOverview',
        name: '平台使用分析',
        icon: 'pingtai',
        children: [
            // { path: '/home/exueMonitoring', component: exueMonitoring, name: 'e学云平台监控'},
            { path: '/home/dataOverview', component: dataOverview, name: '数据总览'},
            {
                path: '/home/userUpdate',
                component: AppMain,
                name: '用户拉新',
                redirect: '/home/areaSchoolCount',
                children: [
                    {
                        path: '/home/areaSchoolCount',
                        component:  areaSchoolCount,
                        name:'区域学校分类'
                    },
                    // {
                    //     path: '/home/classUserCount',
                    //     component:  classUserCount,
                    //     name:'班级用户统计'
                    // },
                    {
                        path: '/home/schoolUserCount',
                        component:  schoolUserCount,
                        name:'学校用户统计'
                    },
                    {
                        path: '/home/newAddUserCount',
                        component:  newAddUserCount,
                        name:'新增用户'
                    }
                ]
            },
            {
                path: '/home/userActivityTrend',
                component: AppMain,
                name: '用户活跃',
                redirect: '/home/userActivityTrend',
                children: [
                    {
                        path: '/home/userActivityTrend',
                        component:  userActivityTrend,
                        name:'用户活跃趋势'
                    },
                    {
                        path: '/home/rolesActiveDetail',
                        component:  rolesActiveDetail,
                        name:'角色活跃明细'
                    },
                    {
                        path: '/home/userActiveFrequency',
                        component:  userActiveFrequency,
                        name:'用户活跃频数'
                    },
                    {
                        path: '/home/activeModules',
                        component:  activeModules,
                        name:'活跃模块'
                    },
                ]
            },
            {
                path: '/home/retenAnalyze',
                component: AppMain,
                name: '用户留存',
                redirect: '/home/retenAnalyze',
                children: [
                    {
                        path: '/home/retenAnalyze',
                        component:  retenAnalyze,
                        name:'用户留存分析'
                    },
                    {
                        path: '/home/retenStatistics',
                        component:  retenStatistics,
                        name:'用户留存统计'
                    }
                ]
            },
            {
                path: '/home/userLoginStatus',
                component: AppMain,
                name: '使用深度',
                redirect: '/home/userStayLength',
                children: [
                    // {
                    //     path: '/home/userLoginStatus',
                    //     component:  userLoginStatus,
                    //     name:'用户登录情况'
                    // },
                    {
                        path: '/home/userStayLength',
                        component:  userStayLength,
                        name:'用户停留时长'
                    }
                ]
            },
            {
                path: '/home/cashConsumption',
                component: AppMain,
                name: '平台消费情况',
                redirect: '/home/cashConsumption',
                children: [
                    {
                        path: '/home/cashConsumption',
                        component:  cashConsumption,
                        name:'现金消费量'
                    },
                    {
                        path: '/home/cashConsuContent',
                        component:  cashConsuContent,
                        name:'现金消费内容'
                    },
                    // {
                    //     path: '/home/serviceStatistics',
                    //     component:  serviceStatistics,
                    //     name:'服务统计'
                    // }
                ]
            },
            {
                path: '/home/machineTypeDistribute',
                component: AppMain,
                name: '设备终端分析',
                redirect: '/home/machineTypeDistribute',
                children: [
                    {
                        path: '/home/machineTypeDistribute',
                        component:  machineTypeDistribute,
                        name:'机型分布'
                    },
                    // {
                    //     path: '/home/resolutionDistribute',
                    //     component:  resolutionDistribute,
                    //     name:'分辨率分布'
                    // },
                    // {
                    //     path: '/home/eCloudDistribute',
                    //     component:  eCloudDistribute,
                    //     name:'e学云版本分布'
                    // }
                ]
            },
            {
                path: '/home/changesSee',
                component: AppMain,
                name: '异动侦查',
                redirect: '/home/changesSee',
                children: [
                    {
                        path: '/home/changesSee',
                        component:changesSee,
                        name:'提现金额排序'
                    },
                    {
                        path: '/home/creditCount',
                        component:creditCount,
                        name:'积分获取量排序'
                    },
                ]
            }
        ]
    },
    {
        path: '/manageAnalysis',
        redirect: '/manageAnalysis/homework',
        component: Layout,
        icon: 'guanlifenxi',
        name: "管理指标分析",
        children: [
            {
                path: '/manageAnalysis/homework', 
                component: AppMain,
                name: '作业分析',
                redirect: '/manageAnalysis/homework',
                children: [
                    { path: '/manageAnalysis/homework', component: homework, name: '作业数据总览' },
                    { path: '/manageAnalysis/question', component: question, name: '题库作业' },
                    { path: '/manageAnalysis/outHomeWork', component: outHomeWork, name: '课外作业' },
                ]
            },
            {
                path: '/studentAnalysis', 
                component: AppMain,
                name: '学情综合分析',
                redirect: '/studentAnalysis/weaknessKnowledge',
                children: [
                    // { path: '/studentAnalysis/weaknessKnowledge', component: weaknessKnowledge, name: '薄弱知识点Top100' },
                    { path: '/studentAnalysis/knowledgeExercise', component: knowledgeExercise, name: '知识点练习量Top100' }
                ]
            },
            {
                path: '/manageAnalysis/dataAnalysis', 
                component: AppMain,
                name: '提分中心',
                redirect: '/manageAnalysis/dataAnalysis',
                children: [
                    { path: '/manageAnalysis/dataAnalysis', component: mentionSubCenter, name: '提分数据分析' }
                ]
            },
            {  path: '/manageAnalysis/classStudy', component: classStudy, name: '课程学习'},
            // {  path: '/manageAnalysis/flyClass', component: flyClass, name: '空中课堂'},
            { path: '/manageAnalysis/liveServiceStatistics', component: liveServiceStatistics, name: 'e直播服务分析' },
            // {
            //     path: '/manageAnalysis/liveServiceStatistics', 
            //     component: AppMain,
            //     name: 'e直播服务分析',
            //     redirect: '/manageAnalysis/liveServiceStatistics',
            //     children: [
            //         { path: '/manageAnalysis/liveServiceStatistics', component: liveServiceStatistics, name: '直播服务统计' },
            //         { path: '/manageAnalysis/LiveDetailStatistics', component: LiveDetailStatistics, name: '直播明细统计' }
            //     ]
            // },
            {  path: '/manageAnalysis/creditShop', component: creditShop, name: '积分商城'},
            // {
            //     path: '/manageAnalysis/integralChartStatistics', 
            //     component: AppMain,
            //     name: '积分情况分析',
            //     redirect: '/manageAnalysis/integralChartStatistics',
            //     children: [
            //         { path: '/manageAnalysis/integralChartStatistics', component: integralChartStatistics, name: '积分图表统计' },
            //         { path: '/manageAnalysis/integralDetailStatistics', component: integralDetailStatistics, name: '积分明细统计' }
            //     ]
            // },
            {  path: '/manageAnalysis/funnelAnaly', component: funnelAnaly, name: '漏斗分析'},
            {  path: '/manageAnalysis/advert', component: advert, name: '广告'},
            {  path: '/manageAnalysis/activityManage', component: newbieTask, name: '新手任务'}
        ]
    },
   
   // 系统
   {
        path: '/systemManage',
        component: Layout,
        name: '系统',
        icon: 'xitong',
        redirect: '/systemManage/list',
        meta: {
            cache: 'userManage,authority'
        },
        children: [
            { path: '/systemManage/list', component: userManage, name: '员工管理' },
            { 
                path: '/systemManage/authoritySet', 
                redirect: '/systemManage/authority',
                component: AppMain, 
                name: '权限管理' ,
                noDropdown: true,
                children: [
                    { path: '/systemManage/authority', component: authority},
                    { path: '/systemManage/addAuthor', component: addAuthor, name: '添加角色'},
                    { path: '/systemManage/editAuthor/:pId', component: editAuthor, name: '修改权限' },
                    { path: '/systemManage/showAuthor/:pId', component: showAuthor, name: '查看权限' }
                ]
            }, 
        ]
    },
    
    // {
    //     path: '/authority',
    //     redirect: 'authority/index',
    //     component: Layout,
    //     icon: 'quanxian',
    //     name: "快捷入口"
    // },
    // {
    //     path: '/userInfor',
    //     redirect: '/userInfor/updataPassword',
    //     component: Layout,
    //     icon: 'quanxian',
    //     name: "用户",
    //     children: [
    //         { path: '/userInfor/updataPassword', component: updataPassword, name: '修改密码' },
    //     ]
    // },
    { path: '*', redirect: '/404', hidden: true }
];